//
//  ZTHistoryTableViewCell.m
//  XMLYFM
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 zzl. All rights reserved.
//

#import "ZTHistoryTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>

#define WIDTH [[UIScreen mainScreen] bounds].size.width

#define HEIGHT [[UIScreen mainScreen] bounds].size.height

@implementation ZTHistoryTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createCell];
    }
    
    return self;
}

-(void)createCell
{
    self.newsPic = [UIImageView new];
    self.newsPic.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.newsPic];
    
    [self.newsPic mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(WIDTH * 0.03);
        make.left.equalTo(self.contentView).offset(WIDTH * 0.03);
        make.width.offset(WIDTH * 0.24);
        make.height.offset(WIDTH * 0.24);
        
    }];
    
    
    self.newsTitle = [UILabel new];
    self.newsTitle.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.newsTitle];
    self.newsTitle.numberOfLines = 0;
    [self.newsTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.newsPic.mas_right).offset(10);
        make.top.equalTo(self.contentView).offset(WIDTH * 0.03);
        make.width.offset(WIDTH * 0.63);
        make.height.offset(HEIGHT * 0.07);
        
        
    }];
    
    
    
    self.newsDigest = [UILabel new];
    self.newsDigest.backgroundColor = [UIColor clearColor];
    self.newsDigest.font = [UIFont systemFontOfSize:13 weight:0];
    [self.contentView addSubview:self.newsDigest];
    self.newsDigest.textColor = [UIColor lightGrayColor];
    self.newsDigest.numberOfLines = 2;
    
    [self.newsDigest mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.newsPic.mas_right).offset(10);
        make.top.equalTo(self.newsTitle.mas_bottom).offset(WIDTH * 0.03);
        make.width.offset(WIDTH * 0.6);
        make.height.offset(HEIGHT * 0.03);
        
        
    }];
    
    
    self.nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.nextBtn.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.nextBtn];
    
    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(WIDTH - 40);
        make.top.equalTo(self.contentView).offset(50);
        make.width.offset(30);
        make.height.offset(30);
        
    }];
    
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(100);
        make.top.equalTo(self.newsPic.mas_bottom).offset(10);
        make.width.offset(WIDTH - 100);
        make.height.offset(0.5);
        
    }];
    
    
}

- (void)setModel:(ZTAlbumModel *)model
{
    _model = model;
    
    NSURL *url = [NSURL URLWithString:model.coverLarge];
    [self.newsPic sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"loading.jpg"]];
    self.newsTitle.text = model.title;
    self.newsDigest.text = model.personInfo;
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
